Started with the separated DB with the given code
[RRRRHHHH_Code] / ruralHouses client / src / gui / StartWindow.java
1 package gui;
2
3 /**
4  * @author willCodeForFood
5  */
6 import java.awt.Color;
7 import java.awt.Font;
8 import java.awt.KeyEventDispatcher;
9 import java.awt.KeyboardFocusManager;
10 import java.awt.event.KeyEvent;
11 import java.awt.event.WindowAdapter;
12 import java.awt.event.WindowEvent;
13 import java.rmi.RMISecurityManager;
14
15 import javax.swing.JButton;
16 import javax.swing.JFrame;
17 import javax.swing.JLabel;
18 import javax.swing.JPanel;
19 import javax.swing.SwingConstants;
20 import javax.swing.UIManager;
21
22
23 @SuppressWarnings("deprecation")
24 public class StartWindow extends JFrame {
25
26         private static final long serialVersionUID = 1L;
27
28         private JPanel jContentPane = null;
29         private JButton boton2 = null;
30         private JButton boton3 = null;
31         private JLabel lblNewLabel;
32
33         public static void main(String[] args) {
34
35                 StartWindow a = new StartWindow();
36                 
37                 System.setProperty("java.security.policy", "java.policy");
38                 
39                 a.setVisible(true);
40
41                 try {
42
43                         System.setProperty("java.security.policy", "java.policy");
44
45                         System.setSecurityManager(new RMISecurityManager());
46
47                         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
48
49                 } catch (com.db4o.ext.DatabaseFileLockedException e) {
50                         a.lblNewLabel
51                                         .setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
52                         a.lblNewLabel.setForeground(Color.RED);
53                         System.out.println("Error in StartWindow: " + e.toString());
54                 } catch (Exception e) {
55                         a.lblNewLabel.setText("Error: " + e.toString());
56                         a.lblNewLabel.setForeground(Color.RED);
57                         System.out.println("Error in StartWindow: " + e.toString());
58                 }
59
60         }
61
62         /**
63          * This is the default constructor
64          */
65
66         public StartWindow() {
67                 super();
68
69                 addWindowListener(new WindowAdapter() {
70                         @Override
71                         public void windowClosing(WindowEvent e) {
72
73                                 System.exit(1);
74                         }
75
76                 });
77
78                 KeyboardFocusManager.getCurrentKeyboardFocusManager()
79                                 .addKeyEventDispatcher(new KeyEventDispatcher() {
80
81                                         @Override
82                                         public boolean dispatchKeyEvent(KeyEvent e) {
83                                                 switch (e.getKeyCode()) {
84
85                                                 case KeyEvent.VK_ESCAPE:
86                                                         System.exit(1);
87                                                 
88                                                 }
89                                                 return false;
90                                         }
91                                 });
92                 initialize();
93                 // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
94         }
95
96         /**
97          * This method initializes this
98          * 
99          * @return void
100          */
101         private void initialize() {
102                 // this.setSize(271, 295);
103                 this.setSize(495, 290);
104                 this.setContentPane(getJContentPane());
105                 this.setTitle("Rural Houses");
106         }
107
108         /**
109          * This method initializes jContentPane
110          * 
111          * @return javax.swing.JPanel
112          */
113         private JPanel getJContentPane() {
114                 if (jContentPane == null) {
115                         jContentPane = new JPanel();
116                         jContentPane.setLayout(null);
117                         jContentPane.add(getLblNewLabel());
118                         jContentPane.add(getBoton2());
119                         jContentPane.add(getBoton3());
120                 }
121                 return jContentPane;
122         }
123
124         /**
125          * This method initializes boton2
126          * 
127          * @return javax.swing.JButton
128          */
129         private JButton getBoton2() {
130                 if (boton2 == null) {
131                         boton2 = new JButton();
132                         boton2.setBounds(0, 74, 479, 93);
133                         boton2.setText("Login");
134                         boton2.addActionListener(new java.awt.event.ActionListener() {
135                                 public void actionPerformed(java.awt.event.ActionEvent e) {
136                                         // C?digo cedido por la universidad
137                                         JFrame a = new LoginGUI();
138                                         a.setVisible(true);
139                                 }
140                         });
141                 }
142                 return boton2;
143         }
144
145         /**
146          * This method initializes boton3
147          * 
148          * @return javax.swing.JButton
149          */
150         private JButton getBoton3() {
151                 if (boton3 == null) {
152                         boton3 = new JButton();
153                         boton3.setBounds(0, 165, 479, 87);
154                         boton3.setText("Query availability");
155                         boton3.addActionListener(new java.awt.event.ActionListener() {
156                                 public void actionPerformed(java.awt.event.ActionEvent e) {
157                                         // C?digo cedido por la universidad
158                                         // JFrame a = new QueryAvailabilityWindow();
159                                         JFrame a = new QueryAvailabilityGUI2();
160
161                                         a.setVisible(true);
162                                 }
163                         });
164                 }
165                 return boton3;
166         }
167
168         private JLabel getLblNewLabel() {
169                 if (lblNewLabel == null) {
170                         lblNewLabel = new JLabel("Select option:");
171                         lblNewLabel.setBounds(0, 0, 479, 63);
172                         lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13));
173                         lblNewLabel.setForeground(Color.BLACK);
174                         lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
175                 }
176                 return lblNewLabel;
177         }
178
179 } // @jve:decl-index=0:visual-constraint="0,0"
180